﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
    Layout = null;
}
<link href="~/lib/layui/css/layui.css" rel="stylesheet" />
<script src="~/lib/layui/layui.js"></script>
<script src="~/js/js.cookie.js"></script>
<script src="~/js/moment.js"></script>
<script src="~/lib/jquery/dist/jquery.js"></script>

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Demo</title>
    <!-- 请勿在项目正式环境中引用该 layui.css 地址 -->
    <link href="//unpkg.com/layui@2.9.18/dist/css/layui.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/layui@2.8.0/dist/css/layui.css">
    <style>
        .table-container {
            width: 100%;
            overflow-x: auto; /* 设置横向滚动条 */
        }
    </style>

</head>
<body>
    <script src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/layui@2.8.0/dist/layui.js"></script>
    <form class="layui-form" action="">
        <div class="layui-form-item">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">可视耳号</label>
                    <div class="layui-input-block">
                        <input type="text" id="recordAuricle" placeholder="请输入" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">电子耳标号</label>
                    <div class="layui-input-block">
                        <input type="text" id="recordCorpuscle" placeholder="请输入" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">品种</label>
                    <div class="layui-input-block">
                        <select name="city" id="recordBreed" lay-filter="aihao">
                            <option value="">请选择</option>
                            <option value="行政管理">111</option>
                            <option value="生产加工">222</option>
                            <option value="业务销售">333</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">性别</label>
                    <div class="layui-input-block">
                        <select name="city" id="sex" lay-filter="aihao">
                            <option value="">请选择</option>
                            <option value="公">公</option>
                            <option value="母">母</option>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">出生日期</label>
                    <div class="layui-input-inline layui-input-wrap">
                        <input type="date" id="recordDate" lay-verify="date" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">月龄</label>
                    <div class="layui-input-block">
                        <input type="text" id="ageInMonths" placeholder="请输入" class="layui-input">-
                        <input type="text" id="persName22" placeholder="请输入" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">生长阶段</label>
                    <div class="layui-input-block">
                        <select name="city" id="stage" lay-filter="aihao">
                            <option value="0">请选择</option>
                            <option value="1">幼崽</option>
                            <option value="2">成年</option>
                            <option value="3">老年</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">位置</label>
                    <div class="layui-input-block">
                        <select name="city" id="cottageId" lay-filter="aihao">
                            <option value="">栋舍</option>
                            <option value="行政管理">111</option>
                            <option value="生产加工">222</option>
                            <option value="业务销售">333</option>
                        </select>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <select name="city" id="fieldId" lay-filter="aihao">
                                <option value="">栏位</option>
                                <option value="行政管理">111</option>
                                <option value="生产加工">222</option>
                                <option value="业务销售">333</option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">羊只类型</label>
                    <div class="layui-input-block">
                        <select name="city" id="recordType" lay-filter="aihao">
                            <option value="">请选择</option>
                            <option value="公">公</option>
                            <option value="母">母</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">基因等级</label>
                    <div class="layui-input-block">
                        <select name="city" id="gene" lay-filter="aihao">
                            <option value="">请选择</option>
                            <option value="公">公</option>
                            <option value="母">母</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">生产等级</label>
                    <div class="layui-input-block">
                        <select name="city" id="productionGrade" lay-filter="aihao">
                            <option value="0">请选择</option>
                            <option value="1">公</option>
                            <option value="2">母</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">销售等级</label>
                    <div class="layui-input-block">
                        <select name="city" id="salesGrade" lay-filter="aihao">
                            <option value="0">请选择</option>
                            <option value="1">一级</option>
                            <option value="2">二级</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">繁殖状态</label>
                    <div class="layui-input-block">
                        <select name="city" id="reproductiveState" lay-filter="aihao">
                            <option value="0">请选择</option>
                            <option value="1">下崽</option>
                            <option value="2">流崽</option>
                            <option value="3">怀崽</option>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">繁殖状态天数</label>
                    <div class="layui-input-block">
                        <input type="text" id="reproductiveStateDays" placeholder="请输入" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">父耳号</label>
                    <div class="layui-input-inline layui-input-wrap">
                        <input type="date" id="recordFather" lay-verify="date" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">母耳号</label>
                    <div class="layui-input-block">
                        <input type="text" id="recordMother" placeholder="请输入" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">在场状态</label>
                    <div class="layui-input-block">
                        <select name="city" id="presenceStatus" lay-filter="aihao">
                            <option value="0">请选择</option>
                            <option value="1">在场</option>
                            <option value="2">不在场</option>
                        </select>
                    </div>
                </div>
                <button type="button" class="layui-btn layui-bg-red" id="searchBtn" onclick="Show()">查询</button>



                <button type="button" class="layui-btn layui-bg-red" onclick="Addgong(0)" lay-on="test-iframe-curl">新增种公</button>
                <button type="button" class="layui-btn layui-bg-red" onclick="Addmu(1)" lay-on="test-iframe-curl">新增种母</button>
                <button type="button" class="layui-btn layui-bg-red" onclick="Addhou(2)" lay-on="test-iframe-curl">新增后裔</button>

            </div>

        </div>

        <table class="layui-table">
            <thead>
                <tr>
                    <td>序号</td>
                    <td>可视耳号</td>
                    <td>电子耳号</td>
                    <td>品种</td>
                    <td>性别</td>
                    <td>出生日期</td>
                    <td>日龄</td>
                    <td>月龄</td>
                    <td>在场状态</td>
                    <td>阶段</td>
                    <td>类型</td>
                    <td>栋舍</td>
                    <td>栏位</td>
                    <td>繁殖状态</td>
                    <td>是否妊检</td>
                    <td>状态天数</td>
                    <td>生产等级</td>
                    <td>销售等级</td>
                    <td>基因等级</td>
                    <td>出生重</td>
                    <td>断奶重</td>             
                    <td>断奶日期</td>
                    <td>断奶日龄</td>
                    <td>父耳号</td>
                    <td>母耳号</td>
                    <td>单据号</td>
                    <td>初期日期</td>
                    <td>耳号</td>
                    <td>栋舍名称</td>
                    <td>栏位</td>
                    <td>重量（公斤）</td>
                    <td>操作</td>
                </tr>
            </thead>
            <tbody></tbody>
        </table>

        <div id="demo-laypage-all"></div>
    </form>



    <!-- 请勿在项目正式环境中引用该 layui.js 地址 -->
    <script src="//unpkg.com/layui@2.9.18/dist/layui.js"></script>
    <script>
        function Addgong(res) {
            localStorage["recordId"]=res;
            location.href = "/User/SheepFarm";
            
        }
        function Addmu(res) {
            localStorage["recordId"] = res;
            location.href = "/User/SheepFarm";
            
        }
        function Addhou(res) {
            localStorage["recordId"] = res;
            
            location.href = "/User/SheepFarm";
            
        }







        layui.use(function () {
            var form = layui.form
            var laypage = layui.laypage;
            var pageIndex = 1;
            var pageSize = 5;

            Show();
            //羊只档案显示列表
            function Show() {
                if ($("#recordDate").val() == "") {
                    var recordDate = null
                };
                if ($("#ageInMonths").val() == "") {
                    var ageInMonths = 0
                };
                if ($("#cottageId").val() == "") {
                    var cottageId = 0
                };
                if ($("#fieldId").val() == "") {
                    var fieldId = 0
                };
                if ($("#recordType").val() == "") {
                    var recordType = -1
                }
                if ($("#reproductiveStateDays").val() == "") {
                    var reproductiveStateDays = 0
                }
                var recordAuricle = "";
                var recordCorpuscle = $("#recordCorpuscle").val();
                var recordBreed = $("#recordBreed").val();
                var sex = $("#sex").val();
                // var recordDate = $("#recordDate").val();
                // var ageInMonths = $("#ageInMonths").val();
                var stage = $("#stage").val();
                // var cottageId = $("#cottageId").val();
                // var fieldId = $("#fieldId").val();
                // var recordType = $("#recordType").val();
                var productionGrade = $("#productionGrade").val();
                var gene = $("#gene").val();
                var salesGrade = $("#salesGrade").val();
                var reproductiveState = $("#reproductiveState").val();
                // var reproductiveStateDays = $("#reproductiveStateDays").val();
                var recordMother = $("#recordMother").val();
                var recordFather = $("#recordFather").val();
                var presenceStatus = $("#presenceStatus").val();



                $.post({
                    url: 'http://localhost:5269/api/SheepArchive/SheepArchivesQuery',
                    data: JSON.stringify({ recordAuricle: recordAuricle, recordCorpuscle: recordCorpuscle, recordBreed: recordBreed, sex: sex, recordDate: recordDate, ageInMonths: ageInMonths, stage: stage, cottageId: cottageId, fieldId: fieldId, recordType: recordType, productionGrade: productionGrade, gene: gene, salesGrade: salesGrade, reproductiveState: reproductiveState, reproductiveStateDays: reproductiveStateDays, recordMother: recordMother, recordFather: recordFather, presenceStatus: presenceStatus, pageIndex: pageIndex, pageSize: pageSize }),
                    async: false,
                    dataType: "json",
                    contentType: "application/json",
                    success: res => {
                        var count = "";

                        $.each(res.data, function () {
                            count += `
                                                                                         <tr>
                                                                            <td>${this.recordId}</td>
                                                                                                            <td><a  onclick="xiugai(${this.recordAuricle})">${this.recordAuricle}</a></td>
                                                                            <td>${this.recordCorpuscle}</td>
                                                                            <td>${this.recordBreed}</td>
                                                                            <td>${this.sex}</td>
                                                                            <td>${this.recordDate}</td>
                                                                            <td>日龄</td>
                                                                            <td>月龄</td>
                                                                            <td>在场状态</td>
                                                                            <td>阶段</td>
                                                                            <td>${this.recordType}</td>
                                                                            <td>${this.cottageId}</td>
                                                                            <td>${this.fieldId}</td>
                                                                            <td>繁殖状态</td>
                                                                            <td>是否妊检</td>
                                                                            <td>状态天数</td>
                                                                            <td>生产等级</td>
                                                                            <td>销售等级</td>
                                                                            <td>${this.gene}</td>
                                                                            <td>${this.recordWeight}</td>
                                                                            <td>断奶重</td>
                                                                            <td>断奶日期</td>
                                                                            <td>断奶日龄</td>
                                                                            <td>${this.recordMother}</td>
                                                                            <td>${this.recordFather}</td>

                                                                            <td>${this.recordBorn}</td>
                                                                            
                                                                            <td>${this.recordSite}</td>
                                                                          
                                                                            <td>${this.recordRemark}</td>
                                                                            <td>${this.admissionDate}</td>
                                                                           
                                                                          
                                                                           
                                                                            <td>${this.farmId}</td>
                                                                           
                                                                            
                                                                            <td>${this.sheepImage}</td>
                                                            <td>操作</td>
                                                        </tr>
                                                                                `
                        });

                        //pagedCount = res.pagedCount;
                        //pcount = res.totalCount;
                        $("tbody").html(count);
                        // console.log(res.data)

                        //var page = Math.ceil(res.totalCount / 5);  //总页数
                        console.log(996, pageSize, pageIndex, res);
                        // 完整显示
                        laypage.render({
                            elem: 'demo-laypage-all', // 元素 id
                            curr: pageIndex,//当前页
                            pages: res.pagedCount,    //总页数
                            limit: pageSize,//每页几条
                            limits: [5, 10, 15],
                            count: res.totalCount, // 数据总数
                            layout: ['count', 'prev', 'page', 'first', 'last', 'next', 'limit', 'skip'], // 功能布局
                            jump: function (obj, first) {
                                if (!first) {
                                    console.log(888, obj);
                                    console.log(obj.curr); // 得到当前页，以便向服务端请求对应页的数据。
                                    console.log(obj.limit); // 得到每页显示的条数
                                    pageIndex = obj.curr;
                                    pageSize = obj.limit;
                                    Show();
                                }
                            }
                        });
                    }
                })


            }

        });

        function xiugai(res) {
            localStorage["recordAuricle"] = res;
            location.href = "/Initial/DetailIndex";

        }


    </script>


</body>

</html>
